package com.mini.grpc.transport.netty;

import com.mini.grpc.transport.ClientTransport;
import com.mini.grpc.transport.ServerListener;
import com.mini.grpc.transport.ServerTransport;
import com.mini.grpc.transport.Transport;
import com.mini.grpc.transport.TransportListener;

import java.net.SocketAddress;

/**
 * Http2Transport实现了基于HTTP/2的传输层。
 */
public class Http2Transport implements Transport {
    
    private final boolean useSSL;
    
    /**
     * 创建一个新的Http2Transport
     */
    public Http2Transport() {
        this(false);
    }
    
    /**
     * 创建一个新的Http2Transport
     *
     * @param useSSL 是否使用SSL
     */
    public Http2Transport(boolean useSSL) {
        this.useSSL = useSSL;
    }
    
    @Override
    public ServerTransport createServer(SocketAddress address, ServerListener listener) {
        return new NettyServerTransport(address, listener, useSSL);
    }
    
    @Override
    public ClientTransport createClient(SocketAddress address, TransportListener listener) {
        return new NettyClientTransport(address, listener, useSSL);
    }
} 